package com.ellecity06.cwhiskymall.ui.mine.auth.result

import com.ellecity06.common.base.BaseMviViewModel
import com.ellecity06.common.ktx.postEvent
import com.ellecity06.cwhiskymall.http.request

/**
 * @author ellecity06
 * @time 2024/10/26 11:53
 * @des
 */
class AuthInfoViewModel : BaseMviViewModel<AuthInfoState, AuthInfoIntent>() {
    private var name :String ?=null
    override suspend fun collectIntent(it: AuthInfoIntent) {
        when (it) {
            is AuthInfoIntent.User -> {
                fetchUser()
            }

            else -> {}
        }
    }



    private fun fetchUser() {
        request(api = { userInfo() }, success = {
            if (it != null){
                mState.postEvent(AuthInfoState.UserInfo(it))

            }
        })
    }
}